/// <reference path="../types/global.d.ts" />
import react from '@vitejs/plugin-react';
import { createStyleImportPlugin, AntdResolve } from 'vite-plugin-style-import';
import createGzip from './gzip';
import alias from '@rollup/plugin-alias';
import { viteMockServe } from 'vite-plugin-mock'


export default function createVitePlugins(viteEnv: ViteEnv, isBuild = false) {
    const isProdEnv = viteEnv.VITE_CURRENT_MODE === 'stage';
    const vitePlugins = [
        alias(),
        react(),
        viteMockServe({
            mockPath: 'mock',
            localEnabled: true,
        }),
        // 按需引用有部分bug存在，如果没有组件没有设置style/index文件，那么vite会打包失败
        // createStyleImportPlugin({
        //     resolves: [AntdResolve()],
        // }),
    ];
    // 使用方式
    const gzip = createGzip();
    vitePlugins.push(gzip);
    return vitePlugins;
}
